#pragma once
#include "MyDlg.h"
#include "resource.h"
#include "RangeSlider.h"
#include "DDAutoDelete.h"
#include "afxcmn.h"
// DlgHistogramBinary dialog

typedef int (WINAPI *OnHistogramBinCBFun)(int nBinary,int nGrayLevels,DWORD dwContext,void *pContext);

class DlgHistogramBinary : public CMyDlg
{
	DECLARE_DYNAMIC(DlgHistogramBinary)

public:
	DlgHistogramBinary(CWnd* pParent = NULL);   // standard constructor
	virtual ~DlgHistogramBinary();

// Dialog Data
	enum { IDD = IDD_HistogramBinary };

public:
    int SetHistogramCBFun(OnHistogramBinCBFun fun,DWORD dwContext,void *pContext);

public:
	int ResetHistogram();
	int SetHistogramInfo(zkImgHistogram *pImgHistogram);

public:
	int SetImgBinary(int nBinary);
	int GetImgBinary(int &nBinary);


public:
	OnHistogramBinCBFun m_CBFun;
	DWORD               m_dwContext;
	void               *m_pContext;


private:
	BOOL         m_bInit;

	CSliderCtrl m_SliderCtrl;
	int         m_nBinary;
	int         m_nGrayLevels;

	DDCriticalSection m_Sect;
	zkImgHistogram   *m_pImgHistogram;

	HPEN  m_hPen1;
	HPEN  m_hPen2;

private:
	CDC     m_MemDC;
	CSize   m_sMemDc;
	CBitmap m_Bitmap;

	int     m_nMemDcHeight; //

	CRect   m_rMap;

private:
	void ShowSquareMap(CDC *pDc);

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnSize(UINT nType, int cx, int cy);

	LRESULT OnRangeChange(WPARAM wParam, LPARAM /* lParam */);
	afx_msg void OnPaint();
	afx_msg void OnDestroy();
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

};
